<template>
  <div>
    <!-- 删除弹框 -->
    <el-dialog
      :title="'删除卡'+'：'+name"
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
      width="750px"
    >
      <div v-loading="loading" class="del-card" element-loading-text="处理中">
        <div class="app-main-tips-box">
          <div class="title">
            <i class="el-icon-warning" /> 删除卡须知
          </div>
          <ul>
            <li>1.删除卡后数据将不可再恢复，如果你只是希望新会员不可开通此会员卡，建议只是暂停此会员卡。</li>
            <li>2.只能删除未有会员的会员卡。</li>
            <!-- <li>2.删除卡后，原使用此会员的会员将切换到你指定的会员卡。</li> -->
            <!-- <li>3.如果你将会员切换到无的状态，这些顾客将需要重新注册其它会员卡才能正常使用。</li> -->
          </ul>
        </div>
        <!-- <el-form label-width="150px" size="mini">
          <el-form-item label="当前会员卡人数：">345</el-form-item>
          <el-form-item label="以上会员切换到：">
            <el-radio-group size="medium" v-model="newId">
              <el-radio :label="0" border>无</el-radio>
              <el-radio
                :label="item.id"
                border
                v-for="item in list"
                :key="item.id"
                :disabled="!item.status||item.id==id"
              >{{item.categoryName}}</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-form>-->
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" round @click="hide">取 消</el-button>
        <el-button size="small" round type="danger" @click="handleSubmit">删除卡</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { delVipCard, getAllVipCardList } from '@/api/vip'
export default {
  data() {
    return {
      // 配置
      resolve: null,
      reject: null,
      // 状态
      dialogVisible: false,
      loading: false,
      // 数据
      id: null,
      name: '',
      // newId: "",
      list: []
    }
  },
  mounted() {
    // this.getList();
  },
  methods: {
    // 获取会员卡列表
    // getList() {
    //   getAllVipCardList()
    //     .then(res => {
    //       this.list = res.data;
    //     })
    //     .catch(err => {});
    // },

    open({ id, name = '' }) {
      this.id = id
      this.name = name
      this.show()
      return new Promise((resolve, reject) => {
        this.resolve = resolve
        this.reject = reject
      })
    },

    show() {
      this.dialogVisible = true
    },

    hide() {
      this.loading = false
      this.dialogVisible = false
    },

    handleSubmit() {
      this.$confirm(`您确定要删除卡：${this.name}, 是否继续?`, '温馨提示', {
        confirmButtonText: '删除',
        cancelButtonText: '取消',
        type: 'warning',
        center: true,
        roundButton: true
      }).then(() => {
        this.loading = true
        delVipCard(this.id)
          .then(res => {
            this.$notify({
              title: '成功',
              message: '删除卡成功',
              type: 'success',
              duration: 2000,
              offset: 40
            })
            this.hide()
            this.resolve && this.resolve()
          })
          .catch(err => {})
          .finally(() => {
            this.loading = false
          })
      })
    }
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
  /* 删除卡弹框 */
</style>
